#region

using System;
using System.ComponentModel.DataAnnotations;
using InfoTech.VinhSon.Bussiness;

#endregion

namespace InfoTech.VinhSon.Models
{
    [Serializable]
    public partial class UserModel
    {
        #region Constructor

        public UserModel()
        {
        }

        public UserModel(User value)
        {
            Id = value.Id;
            Username = value.Username;
            Password = value.Password;
            FirstName = value.FirstName;
            LastName = value.LastName;
            Email = value.Email;
            Activated = value.Activated ?? false;
        }

        #endregion

        #region Fields

        private Boolean _Activated;

        private String _Email;

        private String _FirstName;

        private Int32 _Id;

        private String _LastName;

        private String _Password;

        private String _Username;

        #endregion

        #region Properties

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        public Int32 Id
        {
            get
            {
                return _Id;
            }
            set
            {
                _Id = value;
            }
        }

        [Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        [StringLength(50, ErrorMessage = "Value must be under 50 characters")]
        public String Username
        {
            get
            {
                return _Username;
            }
            set
            {
                _Username = value;
            }
        }

        [Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        [StringLength(50, ErrorMessage = "Value must be under 50 characters")]
        public String Password
        {
            get
            {
                return _Password;
            }
            set
            {
                _Password = value;
            }
        }

        [Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        [StringLength(50, ErrorMessage = "Value must be under 50 characters")]
        public String FirstName
        {
            get
            {
                return _FirstName;
            }
            set
            {
                _FirstName = value;
            }
        }

        [Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        [StringLength(50, ErrorMessage = "Value must be under 50 characters")]
        public String LastName
        {
            get
            {
                return _LastName;
            }
            set
            {
                _LastName = value;
            }
        }

        [Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        [StringLength(50, ErrorMessage = "Value must be under 50 characters")]
        public String Email
        {
            get
            {
                return _Email;
            }
            set
            {
                _Email = value;
            }
        }

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        public Boolean Activated
        {
            get
            {
                return _Activated;
            }
            set
            {
                _Activated = value;
            }
        }

        #endregion

        #region Operators

        public void Update(User value)
        {
            // value.Id = Id;
            value.Username = Username;
            value.Password = Password;
            value.FirstName = FirstName;
            value.LastName = LastName;
            value.Email = Email;
            value.Activated = Activated;
        }

        public static implicit operator UserModel(User obj)
        {
            return new UserModel(obj);
        }

        public static implicit operator User(UserModel obj)
        {
            User value = new User();
            obj.Update(value);
            return value;
        }

        #endregion
    }
}
